fix(lit-query): add DataTag to the queryKey returned by infiniteQueryOptions - #11146
fix(lit-query): add DataTag to the queryKey returned by infiniteQueryOptions#11146lazerg wants to merge 1 commit into
Conversation
📝 WalkthroughWalkthrough
ChangesInfinite query type inference
Estimated code review effort: 2 (Simple) | ~10 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
packages/lit-query/src/tests/type-inference.test.ts (1)
211-230: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winCover the error brand and callback updater.
The assertions at Line 217 through Line 219 check only
dataTagSymbol. They do not checkdataTagErrorSymbol, although the return type carriesTError. The value-formsetQueryDatacall also does not verify the callback updater parameter. Add an explicit error type, assertdataTagErrorSymbol, and add a callback-formsetQueryDataassertion.Based on the PR objective and the
DataTagdefinition inpackages/query-core/src/types.ts, this test should cover both brands and the updater path.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/lit-query/src/tests/type-inference.test.ts` around lines 211 - 230, Update the infiniteQueryOptions type-inference test to provide an explicit error type, assert infiniteQueryOpts.queryKey[dataTagErrorSymbol] resolves to that error type, and add a callback-form client.setQueryData assertion that verifies the updater receives InfiniteData<{ page: number }> | undefined and returns the expected data type. Preserve the existing dataTagSymbol and value-form assertions.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@packages/lit-query/src/tests/type-inference.test.ts`:
- Around line 211-230: Update the infiniteQueryOptions type-inference test to
provide an explicit error type, assert
infiniteQueryOpts.queryKey[dataTagErrorSymbol] resolves to that error type, and
add a callback-form client.setQueryData assertion that verifies the updater
receives InfiniteData<{ page: number }> | undefined and returns the expected
data type. Preserve the existing dataTagSymbol and value-form assertions.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 7a0cc58d-9d78-423f-9721-bccbbad7b874
📒 Files selected for processing (3)
.changeset/wise-doors-shout.mdpackages/lit-query/src/infiniteQueryOptions.tspackages/lit-query/src/tests/type-inference.test.ts
🎯 Changes
infiniteQueryOptionsin lit-query returns the options unchanged, without theDataTagbrand its ownqueryOptionsalready applies. ThequeryKeycarries no data type, soclient.getQueryData(opts.queryKey)andsetQueryDatafall back tounknownand the updater argument can't be used.The return type now intersects
queryKey: DataTag<TQueryKey, InfiniteData<TQueryFnData>, TError>, mirroringqueryOptions.tshere andinfiniteQueryOptionsin react-query. Added a case totype-inference.test.tsnext to the existingqueryOptionsone.Fixes #11142
✅ Checklist
pnpm run test:pr.Local verification detail:
vitest runandtest:typesonlit-query, 102 tests passed, no type errors. The new assertions fail onmain, wheregetQueryDataresolves tounknown.🚀 Release Impact